package bavaria.hightech.testit;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;

import bavaria.hightech.banking.Account;
import bavaria.hightech.banking.BankImpl;
import bavaria.hightech.banking.ECurrency;
import bavaria.hightech.banking.Money;
import bavaria.hightech.exception.WrongValueException;
//import bavaria.hightech.banking.E_Kontoart;
import bavaria.hightech.timer.InternalClock;

public class BankImplTest {
	private static InternalClock timer;

	/**
	 * @param args
	 * @throws WrongValueException 
	 */
	public static void main(String[] args) throws WrongValueException {
		
		
		//exclusive internal clock instance
		timer = InternalClock.getInstance();
		BankImpl bankImpl = new BankImpl("de", "de");
		Account a = bankImpl.openCurrentAccount("Daniel Fuss");
		Account b = bankImpl.openLoanAccount("Christian Adler", 3);
//		Account c = bankImpl.openLoanAccount("So ein Scheiss", 5);
		bankImpl.cashInValue(a.getAccountNumber(), new Money(1000, ECurrency.EUR), "Einzahlung");
		bankImpl.cashInValue(a.getAccountNumber(), new Money(3000, ECurrency.USD), "Einzahlung");
		bankImpl.cashOutValue(a.getAccountNumber(), new Money(2000, ECurrency.EUR), "Auszahlung");
		bankImpl.cashOutValue(a.getAccountNumber(), new Money(500, ECurrency.EUR), "Auszahlung");
		OutputStream out;
		try {
			out = new FileOutputStream("./statement.txt");
			bankImpl.statement(a.getAccountNumber(), out, "text/plain" ,"Date");
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		}
		System.out.println(bankImpl.list());
		try {
			Thread.sleep(35000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
//		System.out.println(bankImpl.statement(a.getAccountNumber(), "Reason"));

//		try {
//			Thread.sleep(40000);
//			bankImpl.payInterest(InternalClock.getCalendar());
//			System.out.println(bankImpl.statement(a.getAccountNumber()));
//			Thread.sleep(2000);
//			bankImpl.payInterest(InternalClock.getCalendar());
//			System.out.println(bankImpl.statement(a.getAccountNumber()));
//			Thread.sleep(2000);
//			bankImpl.payInterest(InternalClock.getCalendar());
//			System.out.println(bankImpl.statement(a.getAccountNumber()));
//		} catch (InterruptedException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//
	}

}
